#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>

from __future__ import (unicode_literals, division, absolute_import,
                        print_function)
import sys
import subprocess
import os

base = os.path.dirname(os.path.abspath(__file__))


def run(cmd):
    ret = subprocess.Popen(cmd).wait()
    if ret != 0:
        raise SystemExit(ret)


def r(cmd):
    args = cmd.split()
    do_shutdown = args[0] != 'linux' and (len(args) == 1 or args[1] == '32')
    args[0] = os.path.join(base, args[0])
    run(args + sys.argv[1:])
    if do_shutdown:
        run([args[0], 'shutdown'])


if len(sys.argv) < 2:
    raise SystemExit('Usage: {} names-of-dependencies-to-build'.format(sys.argv[0]))

r('linux 64'), r('linux 32')
r('win 64'), r('win 32')
r('osx')
